using System.Drawing;
using System.Drawing.Drawing2D;
using CloudShot.Utils;
using CloudShot.Utils.Drawings;

namespace CloudShot.Editor.CanvasFigures
{
  /// <summary>
  ///   Ellipse graphic object
  /// </summary>
  public class CanvasEllipse : CanvasRectangle
  {
    public CanvasEllipse() : this(0, 0, 1, 1) {}

    public CanvasEllipse(int x, int y, int width, int height)
    {
      Rectangle = new Rectangle(x, y, width, height);
    }

    public override void Draw(Graphics graphics)
    {
      Rectangle rect = Rectangle.GetNormalizedRectangle();

      using (Pen pen = CreateBorderPen())
      using (Brush brush = CreateBackBrush())
      using (var path = new GraphicsPath())
      {
        path.AddEllipse(rect);
        path.CloseFigure();

        if (LineType != LineType.None)
        {
          graphics.DrawSmallShadow(path, pen);
        }

        graphics.FillPath(brush, path);

        if (LineType != LineType.None)
        {
          graphics.DrawPath(pen, path);
        }
      }
    }

    protected override CanvasObject CloneIntrenal()
    {
      var clone = new CanvasEllipse();
      SetCloneProperties(clone);
      return clone;
    }
  }
}